﻿/**
*AuthInfo class
*auth:lww
*version:1.0
*date:2014-10-11
*/
function AuthInfo() {  
    this.name = "AuthInfo";
    this.version = "1.0.0";
    /**
    *auth user
    */
    this.userId = null;
    this.userName = null;
    this.nickName = null;
    this.userEmail = null;
    this.roles = null;
    /**
    *auth token
    */  
    this.authToken = null;
    this.crsfToken = null;
    this.extras = null;
}
AuthInfo.prototype.getUserName = function(){
    return this.userName;
};
AuthInfo.prototype.getExtrasInfo = function (key){
    if(this.extras){
        return this.extras[key];
    }
    return null;
}

/**
 * getAuthInfo
 * @param {*} res 
 * @returns instance of AuthInfo
 */
function getAuthInfo(resObj){    
    var authInfo = new AuthInfo();
    if(isNull(resObj)){
        return authInfo;
    }
    authInfo.userId = resObj.data.userId;
    authInfo.userName = resObj.data.userName;
    authInfo.roles = resObj.data.roles;
    authInfo.authToken = resObj.data.authToken;   
    authInfo.extras =  resObj.data.extras;  
    return authInfo;
}



markscript("AuthInfo");
//end AuthInfo.js